package com.beta.auth.utils;

/**
 * @author zdwang
 * @date 2021年09月01日 20:58
 */
public class HttpUtils {

    private HttpUtils(){}
    /**
     * @param url
     * @param name
     * @return java.lang.String
     * @author zdwang
     * @date 2021/9/1 20:59
     */
    public static String getUrlParam(String url, String name) {
        String params = url.substring(url.indexOf("?") + 1);
        String[] kvs = params.split("&");
        String[] var4 = kvs;
        int var5 = kvs.length;

        for (int var6 = 0; var6 < var5; ++var6) {
            String kv = var4[var6];
            String[] kav = kv.split("=");
            if (kav.length == 2 && kav[0].equals(name)) {
                return kav[1];
            }
        }
        return "";
    }

    /**
     * @param params
     * @param name
     * @return java.lang.String
     * @author zdwang
     * @date 2021/9/1 20:59
     */
    public static String getQueryParam(String params, String name) {
        String[] kvs = params.split("&");
        String[] var4 = kvs;
        int var5 = kvs.length;

        for (int var6 = 0; var6 < var5; ++var6) {
            String kv = var4[var6];
            String[] kav = kv.split("=");
            if (kav.length == 2 && kav[0].equals(name)) {
                return kav[1];
            }
        }
        return "";
    }


    /**
     * 判断链接后面是否带有参数 true：带参数 fasle：无参数
     *
     * @param url
     * @return
     */
    public static Boolean hasParams(String url) {
        // 判断URL是否包含?
        int index = url.lastIndexOf("?");
        return index != -1;
    }


}
